#ifndef MSGTYPE_H
#define MSGTYPE_H
#include<fstream>
#include<filesystem>
#include<string>
#include<nlohmann/json.hpp>
#include<chrono>
#include<ctime>
#include<iostream>

using namespace std;
using json = nlohmann::json;

enum MsgType{
    characters = 1,
};




//存储消息，先存储一个type,再存储具体内容
class Msg{
private:
    int sender_id; 
    string chat_room_id;
    string time;
    string data;
    int type;
public: 
    ~Msg()=default;

    Msg(const int&sender_id,const string&chat_room_id,const string&time,const string&data,const int&type);
    Msg(json msg_json){
        unserializeMsg(msg_json);
    }

    int getMsgType()const noexcept;

    //Msg存储到聊天室里,所以序列化实现，不需要chat_room_id;
    json serializeMsg( )const ;

    void unserializeMsg(const json&msg_json) ;

    int get_sender_id() const noexcept;
    string get_chat_room_id() const noexcept;
    string get_time() const noexcept;
};



#endif